package pers.zc.activiti.thread.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pers.zc.activiti.thread.closethread.CloseThread;
import pers.zc.activiti.thread.demo.TestDemoOne;

import java.util.concurrent.ExecutionException;

/**
 * @description 线程测试controller
 * @Author Lin FuYuan
 * @date 2020/4/16
 */
@RestController
@RequestMapping("/threadTest")
@ResponseBody
public class ThreadController {
    @Autowired
    private CloseThread closeThread;
    @Autowired
    private TestDemoOne testDemoOne;

    @GetMapping("start")
    public void testStart() {
        try {
            closeThread.start();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    @GetMapping("stop")
    public void testStop() throws ExecutionException, InterruptedException {
        closeThread.stop();
    }

    @GetMapping("future")
    public  void testFuture(){
        closeThread.testFuture();
    }

    @GetMapping("add")
    public void futureAdd(){
        closeThread.testFutureAdd();
    }


    @GetMapping("/bean")
    public void testAsyncGetBean(){
        testDemoOne.test();
    }
}
